package cn.stylefeng.guns.sys.modular.system.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.modular.system.entity.WorkOrderShenpi;
import cn.stylefeng.guns.sys.modular.system.model.params.WorkOrderShenpiParam;
import cn.stylefeng.guns.sys.modular.system.model.result.WorkOrderShenpiResult;
import cn.stylefeng.guns.sys.modular.system.service.workOrderShenpiService;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/workOrderShenpi")
public class WorkOrderShenpiController {

    private String PREFIX = "/modular/system/workOrderShenpi";

    @Autowired
    private workOrderShenpiService workOrderShenpiService;

    /**
     * 跳转到主页面
     *
     * @author
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/workOrderShenpi.html";
    }

    /**
     * 新增页面
     *
     * @author
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/workOrderShenpi_add.html";
    }

    /**
     * 编辑页面
     *
     * @author
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/workOrderShenpi_edit.html";
    }

    /**
     * 新增接口
     *
     * @author
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(WorkOrderShenpiParam workOrderShenpiParam) {
        return this.workOrderShenpiService.add(workOrderShenpiParam);
    }


    /**
     * 编辑接口
     *
     * @author
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(WorkOrderShenpiParam workOrderShenpiParam) {
        return this.workOrderShenpiService.update(workOrderShenpiParam);
    }


    /**
     * 删除接口
     *
     * @author
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(WorkOrderShenpiParam workOrderShenpiParam) {
        this.workOrderShenpiService.delete(workOrderShenpiParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(WorkOrderShenpiParam workOrderShenpiParam) {
        WorkOrderShenpiResult detail = this.workOrderShenpiService.detail(workOrderShenpiParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(WorkOrderShenpiParam workOrderShenpiParam) {
        return this.workOrderShenpiService.findPageBySpec(workOrderShenpiParam);
    }

}
